package com.uzai.console.web.app;

import com.uzai.console.dto.app.customlink.AppCustomLinkDto;
import com.uzai.console.dto.app.customlink.AppCustomLinkQuery;
import com.uzai.console.service.app.AppCustomLinkService;
import com.uzai.console.vo.app.customLink.AppCustomLinkVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(value = "APP个人中心八宫格自定义链接",tags = "APP个人中心八宫格自定义链接")
@RestController
@RequestMapping(value = "/appCustomLink")
public class AppCustomLinkController extends BaseController {


    @Autowired
    private AppCustomLinkService appCustomLinkService;


    @ApiOperation(value = "分页查询APP自定义链接列表", notes = "分页查询APP自定义链接列表", response = AppCustomLinkVo.class)
    @PostMapping("/queryAppCustomLinkList")
    public Object queryAppCustomLinkList(@RequestBody AppCustomLinkQuery appCustomLinkQuery)throws Exception{
        return appCustomLinkService.queryAppCustomLinkList(appCustomLinkQuery);
    }

    @ApiOperation(value = "查询APP自定义链接", notes = "查询APP自定义链接", response = AppCustomLinkVo.class)
    @PostMapping("/queryAppCustomLink")
    public Object queryAppCustomLink(@RequestBody AppCustomLinkDto appCustomLinkDto)throws Exception{
        return appCustomLinkService.queryAppCustomLink(appCustomLinkDto);
    }


    @ApiOperation(value = "添加APP自定义链接", notes = "添加APP自定义链接", response = boolean.class)
    @PostMapping("/addAppCustomLinkList")
    public Object addAppCustomLinkList(@RequestBody AppCustomLinkDto appCustomLinkDto) throws Exception{
        appCustomLinkService.addAppCustomLinkList(appCustomLinkDto);
        return true;
    }


    @ApiOperation(value = "修改APP自定义链接", notes = "修改APP自定义链接", response = boolean.class)
    @PostMapping("/updateAppCustomLinkList")
    public Object updateAppCustomLinkList(@RequestBody AppCustomLinkDto appCustomLinkDto)throws Exception{
        appCustomLinkService.updateAppCustomLinkList(appCustomLinkDto);
        return true;
    }

    @ApiOperation(value = "删除APP自定义链接", notes = "删除APP自定义链接", response = boolean.class)
    @PostMapping("/deleAppCustomLink")
   public Object deleAppCustomLink(@RequestBody AppCustomLinkDto appCustomLinkDto)throws Exception{
        appCustomLinkService.deleAppCustomLink(appCustomLinkDto);
        return true;
   }


    @ApiOperation(value = "复制cms自定义链接列表", notes = "复制cms自定义链接列表", response = AppCustomLinkVo.class)
    @PostMapping("/copyCmsCustomLink")
   public Object copyCmsCustomLink()throws Exception{
        return appCustomLinkService.copyCmsCustomLink(getLoginInfo().getMerId());
   }

    @ApiOperation(value = "复制app官方自定义链接列表", notes = "复制app官方自定义链接列表", response = AppCustomLinkVo.class)
    @PostMapping("/copyDefaultAppCustomLink")
   public Object copyDefaultAppCustomLink(){
        Long merId = getLoginInfo().getMerId();
      return appCustomLinkService.copyDefaultAppCustomLink(merId);
   }

}
